package la.bbs558.myassert;

import la.bbs558.exception.BusinessException;
import la.bbs558.exception.MsgException;

/**
 * @author: WeiHanmin
 * @description: 断言
 * @time: 2021-09-13 10:02:30
 */
public class MyAssert {

    public static void businessAssert(Boolean b) {
        if (!b) {
            throw new BusinessException("业务异常");
        }
    }

    public static void businessAssert(String msg) {
        throw new BusinessException(msg);
    }

    public static void businessAssert(Boolean b, String msg) {
        if (!b) {
            throw new BusinessException(msg);
        }
    }

    public static void msgAssert(Boolean b) {
        if (!b) {
            throw new MsgException("非法参数");
        }
    }

    public static void msgAssert(Boolean b, String msg) {
        if (!b) {
            throw new MsgException(msg);
        }
    }

    public static void msgAssert(String msg) {
        throw new MsgException(msg);
    }


}
